<?php
//-------------------------------------------------------------------------------------------------------
    require_once($config['app_dir'] . '/classes/stockplot.view.php');
    require_once($config['jpgraph']['path'] . 'jpgraph.php');
    require_once($config['jpgraph']['path'] . 'jpgraph_line.php');
    require_once($config['jpgraph']['path'] . 'jpgraph_regstat.php');
    //---------------------------------------------------------------------------------------------------
    class objSparkLineView  extends objStockView implements iErrorHandler, iVisible{
            protected $_show_logo = false;

        public function ClassName() {
            return  __CLASS__;
        }//ClassName

        protected function BuildGraph() {
            if ( $this->isEmpty() )  throw new Exception($this->Error(1));;

            $this->_graph->SetImgFormat(strtoupper($this->type));

            //$this->_graph->SetAlphaBlending();
            $this->_graph->img->SetAntiAliasing();

            $this->_graph->SetBox(false);
            $this->_graph->SetFrame(false); //1

            $this->_graph->SetScale("intlin", $this->_scale['y']['min'], $this->_scale['y']['max'],
                                              $this->_scale['x']['min'], $this->_scale['x']['max']);

            $this->_graph->SetMarginColor('white');
            $this->_graph->SetMargin(0,3,0,0);

            $this->_graph->xaxis->HideLabels();
            $this->_graph->xaxis->HideLine();
            $this->_graph->xaxis->HideTicks(true, true);

            $this->_graph->xgrid->Show(true, false);
            $this->_graph->xaxis->SetMajTickPositions($this->_labels['xmajor']);


            $this->_graph->ygrid->Show(false, false);
            $this->_graph->yaxis->Hide();
            $this->_graph->yaxis->scale->SetGrace(2, 2);

            $stockplot = new StockPlot($this->_stocks['y'], $this->_stocks['x']);
            $stockplot->SetWidth(2);
            $stockplot->SetColor('black','white','darkgray','darkgray');
            $stockplot->HideEndLines();
            $this->_graph->Add($stockplot);

/*
            $ydata=array();
            for( $i=0; $i<count($this->_stocks['x']); $i++) $ydata[$i] = $this->_stocks['y'][2+$i*4];
            $spline = new Spline($this->_stocks['x'], $ydata);
            list($newx,$newy) = $spline->Get(count($this->_stocks['x']) * 3);
            $splineplot = new LinePlot($newy,$newx);
            $splineplot->SetColor('darkgray');
            $this->_graph->Add($splineplot);
*/
            //draw vectors
            if ( !empty($this->_vectors['y']) && !empty($this->_vectors['x']) ) {
                $i=0; $index=0;
                while( $i<count($this->_vectors['y'])-1 ) {
                        $x = array($this->_vectors['x'][$i], $this->_vectors['x'][$i+1]);
                        $y = array($this->_vectors['y'][$i], $this->_vectors['y'][$i+1]);
                        $i+=2;
                        $vectorplot = new VectorPlot($y, $x);
                        $vectorplot->arrow->SetSize(1);
                        $vectorplot->arrow->SetStyle('solid');
                        $vectorplot->arrow->SetWeight(1);

                        $vectorplot->arrow->SetColor($this->_vector_colors[$this->_vectors['colors'][$index++]-1]);
                        $this->_graph->Add($vectorplot);
                } //while
            } //if

            return true;
        } //BuildGraph
    } //class objSparkLineView
//-------------------------------------------------------------------------------------------------------
?>
